<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('来源基本列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>渠道编号：</label>
                                <input type="text" name="channelCode"/>
                            </li>
                            <li>
                                <label>渠道名称：</label>
                                <input type="text" name="channelName"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="source:baseInfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="source:baseInfo:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="source:baseInfo:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="source:baseInfo:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('source:baseInfo:edit')}]];
        var editKeyFlag = [[${@permission.hasPermi('source:baseInfo:editKey')}]];
        var removeFlag = [[${@permission.hasPermi('source:baseInfo:remove')}]];
        var removeIdFlag = [[${@permission.hasPermi('source:baseInfo:removeId')}]];
        var prefix = ctx + "source/baseInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "来源基本",
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                // {
                //     field: 'channelCode',
                //     title: '渠道编号'
                // },
                // {
                //     field: 'type',
                //     title: ''
                // },
                {
                    field: 'channelName',
                    title: '渠道信息',
                    formatter: function (value, row, index) {
                        return row.channelName + '【' + row.channelCode + '】';
                    }
                },
                    {
                        field: 'descInfo',
                        title: '对接类型',
                        formatter: function (value, row, index) {
                            return row.typeStr + '【' + row.type + '】';
                        }
                    },
                {
                    field: 'descInfo',
                    title: '描述信息'
                },
                    {
                        field: 'priceAmount',
                        title: '价格/溢价率/起推价',
                        formatter: function (value, row, index) {
                            return row.priceAmount + '【' + row.priceRate + '】' + '【' + row.startPrice + '】';
                        }
                    },
                    // {
                    //     field: 'priceRate',
                    //     title: '溢价率'
                    // },
                // {
                //     field: 'baseAmount',
                //     title: '基本价格'
                // },
                {
                    field: 'priceType',
                    title: '价格类型/分成比例/撞库成功价',
                    formatter: function (value, row, index) {
                        return row.priceTypeStr + ' / ' + row.profitRate + ' / ' + row.checkMinAmount;
                    }
                },
                // {
                //     field: 'profitRate',
                //     title: '收益分成比例'
                // },

                // {
                //     field: 'flowType',
                //     title: '流程类型'
                // },
                // {
                //     field: 'signType',
                //     title: ''
                // },
                // {
                //     field: 'encryptType',
                //     title: '加密类型'
                // },
                // {
                //     field: 'extData',
                //     title: ''
                // },
                {
                    field: 'statusStr',
                    title: '状态'
                },
                // {
                //     field: 'pushFlag',
                //     title: '是否推送给机构'
                // },
                // {
                //     field: 'settleFlag',
                //     title: '结算方式'
                // },
                // {
                //     field: 'appKey',
                //     title: ''
                // },
                // {
                //     field: 'appSecret',
                //     title: ''
                // },
                // {
                //     field: 'pubKey',
                //     title: ''
                // },
                // {
                //     field: 'priKey',
                //     title: ''
                // },
                // {
                //     field: 'factoryType',
                //     title: ''
                // },


                {
                    field: 'checkTimeout',
                    title: '超时时间(撞库/进件)',
                    formatter: function (value, row, index) {
                        return row.checkTimeout + ' / ' + row.registerTimeout;
                    }
                },

                // {
                //     field: 'registerTimeout',
                //     title: '进件超时时间'
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editKeyFlag + '" href="javascript:void(0)" onclick="editKeyInfo(\'' + row.id + '\')"><i class="fa fa-edit"></i>密钥</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeIdFlag + '" href="javascript:void(0)" onclick="removeId(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function editKeyInfo(id) {
            var url = prefix + "/editKey/" + id;
            $.modal.open('修改密钥信息', url);
        }

        function removeId(id) {
            var url = prefix + "/removeId?id=" + id;

            $.modal.confirm("确定要删除这个机构信息吗？", function() {

                $.ajax({
                    type: "POST",
                    url: url,
                    success: function(data) {
                        if (data.code == 0) {
                            $.modal.msgSuccess("删除成功");
                            $.table.refresh();
                        } else {
                            $.modal.msgError("删除失败：" + data.msg);
                        }
                    },
                    error: function() {
                        $.modal.msgError("操作失败");
                    }
                });
            });
        }


    </script>
</body>
</html>